package com.cw.jeeyt.service.converter.system;

import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.system.SystemModuleInfoBo;
import com.cw.jeeyt.dao.model.system.SystemModuleInfoDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 系统模块转换类
 *
 * @author chenw
 * @date 2019-03-10 13:04:25
 */
public class SystemModuleInfoConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static SystemModuleInfoBo do2Bo(SystemModuleInfoDo model) {
        if (model == null) {
            return null;
        }
        SystemModuleInfoBo bo = new SystemModuleInfoBo();
        bo.setId(model.getId());
        bo.setProjectId(model.getProjectId());
        bo.setModuleCode(model.getModuleCode());
        bo.setModuleName(model.getModuleName());
        bo.setModulePrefix(model.getModulePrefix());
        bo.setBasePackagePath(model.getBasePackagePath());
        bo.setPagePath(model.getPagePath());
        bo.setCreateBy(model.getCreateBy());
        bo.setCreateDate(model.getCreateDate());
        bo.setUpdateBy(model.getUpdateBy());
        bo.setUpdateDate(model.getUpdateDate());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static SystemModuleInfoDo bo2Do(SystemModuleInfoBo bo) {
        if (bo == null) {
            return null;
        }
        SystemModuleInfoDo model = new SystemModuleInfoDo();
        model.setId(bo.getId());
        model.setProjectId(bo.getProjectId());
        model.setModuleCode(bo.getModuleCode());
        model.setModuleName(bo.getModuleName());
        model.setModulePrefix(bo.getModulePrefix());
        model.setBasePackagePath(bo.getBasePackagePath());
        model.setPagePath(bo.getPagePath());
        model.setCreateBy(bo.getCreateBy());
        model.setCreateDate(bo.getCreateDate());
        model.setUpdateBy(bo.getUpdateBy());
        model.setUpdateDate(bo.getUpdateDate());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<SystemModuleInfoBo> doList2BoList(List<SystemModuleInfoDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SystemModuleInfoConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<SystemModuleInfoDo> boList2DoList(List<SystemModuleInfoBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SystemModuleInfoConverter::bo2Do));
    }
}